//
//  ByViewPetCardRecordList.m
//  mijifen_ios
//
//  Created by 朱凯 on 2017/10/26.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByViewPetCardRecordList.h"

// cell
#import "ByCellRecordListItem.h"

@implementation ByViewPetCardRecordList 
{
    UILabel     *_titleLabel;
    UITableView *_table;
    UIButton    *_closeButton;
    
}
- (instancetype)init {
    
    if (self = [super init]) {
        
        self.damping = 0.6;
        self.positionMode = ZKBombPopModeCenter;
        self.popMode = ZKBombPopModeCenter;
        [self disableTapMask];
        [self createContentView];
    }
    return self;
}

- (void)createContentView {
    
    
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH * 0.88, SCREEN_WIDTH * 1.3)];
    contentView.layer.cornerRadius = 4;
    contentView.layer.masksToBounds = true;
    self.contentView = contentView;
    
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.backgroundColor = BY_THEME_COLOR;
    _titleLabel.adjustsFontSizeToFitWidth = true;
    _titleLabel.numberOfLines = 1;
    _titleLabel.text = @"消费记录";
    _titleLabel.font = FONT(18);
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.textColor = BY_GOLD_COLOR;
    [self.contentView addSubview:_titleLabel];

    _table = [[UITableView alloc] init];
    _table.backgroundColor = BY_BG_COLOR;
    _table.separatorStyle = UITableViewCellSeparatorStyleNone;
    _table.delegate = self;
    _table.dataSource = self;
    [self.contentView addSubview:_table];
    
    _closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _closeButton.backgroundColor = BY_THEME_COLOR;
    _closeButton.titleLabel.font = FONT(18);
    [_closeButton setTitle:@"关闭" forState:UIControlStateNormal];
    [_closeButton setTitleColor:BY_GOLD_COLOR forState:UIControlStateNormal];
    [_closeButton addTarget:self action:@selector(close) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:_closeButton];
    
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@44);
    }];
    [_closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(@0);
        make.height.equalTo(@44);
    }];
    [_table mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(@0);
        make.top.equalTo(_titleLabel.mas_bottom);
        make.bottom.equalTo(_closeButton.mas_top);
    }];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    ByCellRecordListItem *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[ByCellRecordListItem alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    cell.status = indexPath.row % 2;
    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 44;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return UIView.new;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return UIView.new;
}

- (void)close {
    
    [self remove];
}

@end
